package com.ysyx.ysyx_driverinfo.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ysyx.ysyx_driverinfo.dto.BaseDto;
import com.ysyx.ysyx_driverinfo.pojo.CarPojo;
import com.ysyx.ysyx_driverinfo.service.CarPojoService;
import com.ysyx.ysyx_driverinfo.mapper.CarPojoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 *
 */
@Service
public class CarPojoServiceImpl extends ServiceImpl<CarPojoMapper, CarPojo>
    implements CarPojoService{


    @Autowired
    private CarPojoMapper carPojoMapper;

    @Override
    public BaseDto getCarByDriverId(Integer driverId) {

        QueryWrapper<CarPojo> carQw = new QueryWrapper<>();
        carQw.eq("driver_id", driverId);


        CarPojo carPojo = carPojoMapper.selectOne(carQw);
        if(carPojo!=null){
            List<CarPojo> carList = new ArrayList<>();
            carList.add(carPojo);
            return new BaseDto(101,"司机车辆查询成功",carList);
        }else{
            return new BaseDto(201,"司机车辆不存在",null);
        }



    }
}




